<?php defined("MAIN_DIR") or die("No direct access");

require_once ADMIN."admin_functions.php";
require_once ADMIN."defines.php";

$user = new User();

// city select
if (!$route->COOKIE('city_admin')) {
	setcookie("city_admin",1,time()+63072000,"/");
	if (!isset($_SESSION['city_admin']))
		$_SESSION['city_admin'] = 1;
} else {
	$_SESSION['city_admin'] = $route->COOKIE('city_admin');
}

$current_admin_city_res = mysql_query("select * from `city` where `city_id` = '$_SESSION[city_admin]' limit 1");
if (mysql_num_rows($current_admin_city_res) == 0) {
	setcookie("city_admin",1,time()+63072000,"/");
	$_SESSION['city_admin'] = 1;
	$current_admin_city_res = mysql_query("select * from `city` where `city_id` = '1' limit 1");
}

$current_admin_city = mysql_fetch_array($current_admin_city_res);

if (!$user->isUser()) {
	require_once ADMIN."authorization.php";
	die;
}

switch ($route->getPath(2)) {
	
	case "banks":		require_once ABANKS.MAINFILE; break;
	case "mentions":	require_once AMENTIONS.MAINFILE; break;
	case "rko":			require_once ARKO.MAINFILE; break;
	case "deposits":	require_once ADEPOSITS.MAINFILE; break;
	case "boxes":		require_once ABOXES.MAINFILE; break;
	case "categories":	require_once ACATEGORIES.MAINFILE; break;
	case "vacancies":	require_once AVACANCIES.MAINFILE; break;
	case "atms":		require_once AATMS.MAINFILE; break;
	case "credits":		require_once ACREDITS.MAINFILE; break;
	case "site":		require_once ASITE.MAINFILE; break;
	
	// ajax
	case "fast_search":	require_once ADMIN."fast_search.php"; break;
	case "ajax_bank":	require_once ADMIN."ajax_bank.php"; break;
	
	/* case "text": $include = ASITE."text.php"; break;
	case "polls": $include = ASITE."polls.php"; break;
	case "users": $include = ASITE."users.php"; break;
	case "cities": $include = ASITE."cities.php"; break;
	 */
	case "logout": $user->logout(); to("/admin/");
	
	default: to("/admin/banks/");
}

?>